package com.bw.module_home.ui.marketers

import android.util.Log
import androidx.activity.viewModels
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.bw.lib_common.base.BaseActivity
import com.bw.module_home.R
import com.bw.module_home.databinding.ActivityResidencyApplicationDetailBinding
import com.bw.module_home.marketer.viewmodel.MarketersViewModel
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
@Route(path = "/module_marketers/residencyApplicationDetailActivity")
class ResidencyApplicationDetailActivity : BaseActivity<MarketersViewModel, ActivityResidencyApplicationDetailBinding>() {
    @Autowired
    @JvmField
    var detailId: Int = 0
    private val viewModel: MarketersViewModel by viewModels()

    override val mLayoutResId: Int
        get() = R.layout.activity_residency_application_detail

    override fun initView() {
        super.initView()
        ARouter.getInstance().inject(this)
        Log.d("id", "${detailId}")
        mBinding.back.setOnClickListener {
            finish()
        }
        mBinding.statusBar.setOnClickListener {
            ARouter.getInstance().build("/module_marketers/marketersActivity")
                .withInt("marketId", detailId)
                .navigation()
        }
        viewModel.getResidencyApplicationDetailById(detailId)
    }

    override fun initListener() {
        super.initListener()
        viewModel.getResidencyApplicationDetailByIdSuccess.observe(this) {
            mBinding.detailEntity = it
            mBinding.applyTime.setText(it.processingSteps.get(0).stepTime)
        }
    }

    override fun onResume() {
        super.onResume()
        viewModel.getResidencyApplicationDetailById(detailId)
    }
}